def main():
    s = input("Enter string:\n")
    s1 = ""
    i = 0
    for i in range(len(s)):
        if s[i] in '([{<':
            s1 += s[i]
        if s[i] == ')' and s1 and s1[-1] == '(':
            s1 = s1[:-1]
        elif s[i] == ']' and s1 and s1[-1] == '[':
            s1 = s1[:-1]
        elif s[i] == '}' and s1 and s1[-1] == '{':
            s1 = s1[:-1]
        elif s[i] == '>' and s1 and s1[-1] == '<':
            s1 = s1[:-1]
        elif s[i] == ']' and (not s1 or s1[-1] != '['):
            break
        elif s[i] == ')' and (not s1 or s1[-1] != '('):
            break
        elif s[i] == '}' and (not s1 or s1[-1] != '{'):
            break
        elif s[i] == '>' and (not s1 or s1[-1] != '<'):
            break
        elif s[i] in ')]}>' and not s1:
            break
    if i == len(s) - 1 and not s1:
        print("True")
    else:
        print("False")

if __name__ == "__main__":
    main()
